#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    port = 8010;
    ui->lineEdit->setText(QString::number(port));
}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_pushButton_clicked()
{
    tcpServer = new TcpServer(this, port);
    connect(tcpServer, SIGNAL(updateServer(QString, int)), this, SLOT(updateServer(QString, int)));
    ui->pushButton->setEnabled(false);
}

void Dialog::updateServer(QString msg, int length)
{
    ui->listWidget->addItem(msg.left(length));
}
